package cn.qidisoft.edu.hzjt.service.zyc.impl;

import java.util.List;
import java.util.Map;

import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.apache.ibatis.session.RowBounds;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.qidisoft.core.common.code.QdfRespCode;
import cn.qidisoft.core.common.exception.dao.DBException;
import cn.qidisoft.core.common.log.LoggerAdapter;
import cn.qidisoft.core.common.log.LoggerAdapterFactory;
import cn.qidisoft.core.common.pagination.Page;
import cn.qidisoft.core.common.pagination.PaginationBean;
import cn.qidisoft.edu.hzjt.dao.zyc.DybMapper;
import cn.qidisoft.edu.hzjt.model.zyc.PartyLeagueMember;
import cn.qidisoft.edu.hzjt.service.zyc.IDyService;
import cn.qidisoft.edu.hzjt.utils.LogType;

@Service
public class DyServiceImpl implements IDyService{
	protected static final LoggerAdapter LOGGER = LoggerAdapterFactory.getLogger(LogType.HZJT_LOGGER.val);
	
	@Autowired
	private DybMapper dybMapper; 
	@Override
	public PaginationBean<PartyLeagueMember> getListData(Map<String, Object> queryMap, Page page) {
		int c = dybMapper.getCounnt(queryMap);
		int totalRecords = 0;
		totalRecords = (int) c;
		PaginationBean<PartyLeagueMember> pageHolder = new PaginationBean<PartyLeagueMember>(page, totalRecords);
		List<PartyLeagueMember> resultList = dybMapper.getListData(queryMap,
				new RowBounds((pageHolder.getCurrentPage() - 1) * pageHolder.getPageSize(), pageHolder.getPageSize()));
		pageHolder.setPageList(resultList);
		return pageHolder;
	}
	@Override
    @Transactional
    public void delete(List<Integer> data) {
        try {
        	dybMapper.delete(data);
        } catch (Exception e) {
            LOGGER.error("delete [{}] error," + this.getClass().getName() + "=[{}]",
                this.getClass().getName(),
                ToStringBuilder.reflectionToString(data, ToStringStyle.SHORT_PREFIX_STYLE));
            throw new DBException(QdfRespCode.QDF_020002.getCode(), QdfRespCode.QDF_020002.getMsg(),
                e);
        }
    }
	@Override
	public List<PartyLeagueMember> getDybList(Map<String, Object> queryMap) {
		return dybMapper.getDybList(queryMap);
	}
	@Override
	public int updateDybinfo(PartyLeagueMember pM) {
		
		return dybMapper.updateDybinfo(pM);
		
	}
	@Override
	public PartyLeagueMember getDybById(Integer parseInt) {
		
		return dybMapper.getDybById(parseInt);
	}
	@Override
	public PartyLeagueMember getDzbId(PartyLeagueMember pMember) {
		
		return dybMapper.getDzbId(pMember);
	}
	@Override
	public PartyLeagueMember selectXm(PartyLeagueMember partyLeagueMember) {
		
		return dybMapper.selectXm(partyLeagueMember);
	}
	
	
	
}
